import fileinput
import sys
import os


def main(basepath):
    for dirname, dirnames, filenames in os.walk(basepath):

        for filename in filenames:
            if filename.endswith(".java"):
                print "fixing linendings in "+filename
                fixFile(os.path.join(dirname, filename))


def fixFile(file):
    for line in fileinput.input(file,inplace=1):
        if "\r\n" in line:
                line = line.replace("\r\n","\n")
        sys.stdout.write(line)

if __name__ == "__main__":
    main("../src")
